<template>
  <el-dialog
    :title="title"
    :visible.sync="visible"
    :width="width"
    :append-to-body="true"
    :destroy-on-close="true"
    :close-on-click-modal="false"
    @close="cancel"
  >
    <slot name="content" />
    <slot name="footer">
      <span slot="footer">
        <el-button @click="cancel">{{ cancelText }}</el-button>
        <el-button type="primary" @click="success">{{ successText }}</el-button>
      </span>
    </slot>
  </el-dialog>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      default: '提示'
    },
    width: {
      type: [String, Number],
      default: '40%'
    },
    visible: {
      type: Boolean,
      default: false
    },
    cancelText: {
      type: String,
      default: '取消'
    },
    successText: {
      type: String,
      default: '确定'
    }
  },
  methods: {
    cancel() {
      const vm = this
      vm.$emit('cancel')
    },
    success() {
      const vm = this
      vm.$emit('success')
    }
  }
}
</script>

<style lang="scss" scoped></style>
